package com.yazi.mxz.common.db.dao.impl;


import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.yazi.mxz.common.db.dao.AddressDao;
import com.yazi.mxz.common.entity.beans.Address;
import com.yazi.mxz.common.entity.beans.Member;

import com.myframework.smhj.hibernate.dao.BasicDao;

@Repository("addressDao")
public class AddressDaoImpl extends BasicDao<Address> implements AddressDao {

	public AddressDaoImpl() {
		super(Address.class);
	}
	
	@Override
	public Criteria getExample(Address address, String searchWord) {
		Criteria c = super.getExample(address, searchWord);
		
		// 关联对象条件
		if (null != address) {
			// 用户
			Member member = address.getMember();
			if (null != member) {
				// 用户ID
				if (null != member.getMemberId()) {
					c.add(Restrictions.eq("member.memberId", member.getMemberId()));
				} else {
					// ...用户其它条件
				}
			}
			// ...其它关联对象条件
		}
		
		// ...关键字searchWord条件
		
		return c;
	}

}
